package com.caption.auth.secuity.handler;
import com.caption.core.utils.ResponseUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.web.access.AccessDeniedHandler;
import org.springframework.stereotype.Component;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @description: 认证拒绝处理类
 * @author: 码农
 * @date: 2021-12-31 19:58:33
 */
@Component
@Slf4j
public class  UserAuthDeniedHandler  implements AccessDeniedHandler {

    @Override
    public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException e) throws IOException, ServletException {
        ResponseUtils.out(response,ResponseUtils.resultCode(403,"未授权"));
    }
}
